import { _decorator, Canvas, Component } from 'cc';
import { ResManager } from './core/modules/res/ResManager';
import { registerBUrlByCfg, UIManager } from './core/modules/ui/UIManager';
import { LoginCtr } from './GamePlay/modules/Login/LoginCtr';
import { Match3UI } from './GamePlay/modules/Match3/Match3UI';
import { PrefabCfg } from './auto/PrefabCfg';
const { ccclass } = _decorator;
// 新增全局变量声明
declare global {
    const gtr: GCtr;
}
@ccclass('GCtr')
class GCtr extends Component {
    readonly loginCtr = new LoginCtr();
    readonly res = new ResManager();
    readonly ui = new UIManager();

async init(param: {
    canvas2d: Canvas,
}) {
    // 全局变量设置
    (globalThis as any)["gtr"] = this;
    // 提前注册预制体信息
    registerBUrlByCfg(PrefabCfg);
    // 界面管理器二段构造
    gtr.ui.init(param.canvas2d);
    // 登录模块二段构造
    gtr.loginCtr.init();
    
    // 显示登录界面（传入登录成功回调函数）
    gtr.loginCtr.showLogin(async () => {
        await gtr.res.loadBundleAsync("Match3BN");
        gtr.ui.open(Match3UI)
    })
}
}